import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'
import './details.less'
var amapFile = require('../../comment/liba/amap-wx.js')

export default class Index extends Component {

  state = {
    imgsrc: ""
  }

  config = {
    navigationBarTitleText: '详情'
  }

  componentWillMount() { }

  componentDidMount() {

    var that = this;
    var myAmapFun = new amapFile.AMapWX({ key: 'e0ae8a59c85794f4a76140aff5a4db04' });

    myAmapFun.getStaticmap({
      zoom: 8,

      scale: 2,
      markers: "mid,0xFF0000,A:116.37359,39.92437;116.47359,39.92437",
      success: function (data) {
        console.log(data, 1)

        that.setState({
          imgsrc: data.url
        })
      },
      fail: function (info) {
        wx.showModal({ title: info.errMsg })
      }
    })



  }

  componentWillUnmount() { }

  componentDidShow() { }

  componentDidHide() { }

  render() {
    return (
      <View className='map_container'>
        <Image
          style='width: 300px;height: 100px;background: #fff;'
          src={imgsrc}
        />
        <map class="map" id="map" longitude="{{longitude}}" latitude="{{latitude}}" scale="14" show-location="true" markers="{{markers}}" bindmarkertap="makertap"></map>
      </View>
    )
  }
}

